﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.EnterpriseServices;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Zuoye;
namespace Zuoye
{
    public partial class Register : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            InitCity();
        }
        public void InitCity()
        {
            DataSet ds = DbHelper.Query("select * from S_City");
            ddlCity.DataSource = ds;
            ddlCity.DataTextField = "CityName";
            ddlCity.DataValueField = "CityID";
            ddlCity.DataBind();
        }

        protected void btnRg_Click(object sender, EventArgs e)
        {
            string account = txtName.Text.Trim();
            string birth = txtBirth.Text.Trim();
            string pwd = txtPwd.Text.Trim();
            int city = Convert.ToInt32(ddlCity.SelectedValue);
            int gender = Convert.ToInt32(rbtnGender.SelectedValue);
            string img = Image1.ImageUrl;
            string phone = txtPhone.Text.Trim();
            string email = txtEmail.Text.Trim();
            string qq = txtQQ.Text.Trim();
            string sql = string.Format("insert into users values('{0}','{1}','{2}',{3},{4},'{5}','{6}','{7}','{8}', 0,0,'',0)", account, birth, pwd, city, gender, img, phone, email, qq);
            int flag = DbHelper.ExecuteSql(sql);
            if (flag > 0)
            {
                Response.Write("<script>alert('注册成功，请等待审核人员审批');</script>");
            }
        }
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            string imgName = fulImg.FileName;
            string path = Server.MapPath("img") + "\\" + imgName;
            if (imgName != "")
            {
                fulImg.SaveAs(path);
                Image1.ImageUrl = "/img/" + imgName;
            }
        }
    }
}